<template>
  <a-modal title='取回审批流程' width='600px' :visible.sync='dialogTaskBackNodesInChild' @cancel='handleCancel' @ok='handlerSubmit'>
    <a-radio-group v-model='backNode' @change='selectBackNode'>
      <a-radio v-for='(item,index) in backNodes' :value='item' :key='index'>
        {{ item.nodeName }} {{ item.userName }}
      </a-radio>
    </a-radio-group>
  </a-modal>
</template>

<script>
import api from "../js/api"

export default {
  name: "RetrieveModel",
  props: {
    visible: {
      type: Boolean,
      default: function() {
        return false
      }
    },
    executeTaskId: {
      type: String,
      default: function() {
        return ""
      }
    }
  },
  data() {
    return {
      api: Object.assign(api, this.api),
      backNode: {},
      dialogTaskBackNodesInChild:false,
      message: "取回",
      backNodes: []
    }
  },
  created() {
  },
  methods: {
    messageChange(value) {
      this.message = value
      this.$forceUpdate()
    },
    handleCancel() {
      this.dialogTaskBackNodesInChild = false
    },
    open(record) {
      this.http.get(this, {
        url: this.api.tasktodo.getBackNodes,
        params: {
          taskId: record.taskId
        },
        success: function(me, data) {
          me.backNodes = [data[data.length-1]]
          me.backNode = me.backNodes[0]
          me.dialogTaskBackNodesInChild = true
        }
      })
    },
    selectBackNode(e) {
      this.backNode = e.target.value
    },
    handlerSubmit() {
      this.dialogTaskBackNodesInChild = false
      this.$emit("backTaskSubmit", this.backNode, this.message)
    }
  }
}
</script>

